<template>
  <view>
    <u-navbar :is-back="true" :title="title"></u-navbar>
    <u-swiper height="400" :list="swiper"></u-swiper>

    <view style="margin-top: 5%">
      <u-card>
        <view slot="body">
          <u-card @click="navigateTo('/pages/article/detail?id='+ob.id)" v-for="ob in news">
            <view slot="body">
              <view style="width: 100%;display: flex">
                <view style="width: 40%">
                  <img style="width: 200rpx;height: 150rpx" :src="ob.cover"/>
                </view>
                <view style="width: 60%">
                  <view style="height: 100rpx" class="u-type-info u-line-2">{{ ob.title }}</view>
                  <view>
                    {{ ob.createTime }}
                  </view>
                </view>
              </view>
            </view>
          </u-card>
        </view>
      </u-card>
    </view>
  </view>
</template>
<script>


import {allSwipers} from "@/api/card/swiper";
import UNavbar from "@/uview-ui/components/u-navbar/u-navbar.vue";
import {allArticles, listArticle} from "@/api/card/article";

export default {
  components: {UNavbar},
  data() {
    return {
      swiper: [],
      news: [],
      type: null,
      title: null,
    }
  },
  onLoad(options) {
    this.type = options.type
    if (this.type == 2) {
      this.title = '新闻中心'
    }
    if (this.type == 3) {
      this.title = '校友风采'
    }
    allArticles({type: this.type}).then(re => {
      this.news = re.data
    })
    allSwipers({type: this.type}).then(re => {
      for (let ob of re.data) {
        this.swiper.push({image: ob.url})
      }
    })
  },
  methods: {},

};
</script>

<style lang="scss" scoped>
.head {
  position: relative;
  height: 500rpx;
  background-image: url('https://njjtj.itssky.com:7991/profile/upload/2024/05/03/background_20240503173112A021.png');
  background-size: cover
}
</style>
